package o;

import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SubtitleDecoderException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import o.ako.a;

public final class aki extends ajh {
    private static final int ˊ = anr.ᐝ("sttg");
    private static final int ˋ = anr.ᐝ("vttc");
    private static final int ˏ = anr.ᐝ("payl");
    private final a ˎ = new a();
    private final anc ॱ = new anc();

    protected /* synthetic */ aji ˎ(byte[] bArr, int i, boolean z) throws SubtitleDecoderException {
        return ˋ(bArr, i, z);
    }

    public aki() {
        super("Mp4WebvttDecoder");
    }

    protected akr ˋ(byte[] bArr, int i, boolean z) throws SubtitleDecoderException {
        this.ॱ.ॱ(bArr, i);
        List arrayList = new ArrayList();
        while (this.ॱ.ˊ() > 0) {
            if (this.ॱ.ˊ() < 8) {
                throw new SubtitleDecoderException("Incomplete Mp4Webvtt Top Level box header found.");
            }
            int ॱᐝ = this.ॱ.ॱᐝ();
            if (this.ॱ.ॱᐝ() == ˋ) {
                arrayList.add(ˊ(this.ॱ, this.ˎ, ॱᐝ - 8));
            } else {
                this.ॱ.ˎ(ॱᐝ - 8);
            }
        }
        return new akr(arrayList);
    }

    private static Cue ˊ(anc o_anc, a aVar, int i) throws SubtitleDecoderException {
        aVar.ˊ();
        while (i > 0) {
            if (i < 8) {
                throw new SubtitleDecoderException("Incomplete vtt cue box header found.");
            }
            int ॱᐝ = o_anc.ॱᐝ();
            int ॱᐝ2 = o_anc.ॱᐝ();
            int i2 = i - 8;
            ॱᐝ -= 8;
            String ˊ = anr.ˊ(o_anc.ˏ, o_anc.ˋ(), ॱᐝ);
            o_anc.ˎ(ॱᐝ);
            i = i2 - ॱᐝ;
            if (ॱᐝ2 == ˊ) {
                akp.ॱ(ˊ, aVar);
            } else if (ॱᐝ2 == ˏ) {
                akp.ˋ(null, ˊ.trim(), aVar, Collections.emptyList());
            }
        }
        return aVar.ˏ();
    }
}
